import { releaseProduct } from "@/api/api";
export default {
  name: 'bidding',

  components: {},
  props: [],
  data() {
    return {
      
      // 上传照片名称
      imageUrl: '',
      
      // listData // 定义的对象
      listData: {},
      // 数据提示
      Pname: "",
      wranGrade:"",
      wranNum:"",
      warnPrice:"",
      // 显示的隐藏
      pnameShow: false,
      gradeShow:false,
      numShow: false,
      priceShow:false,
      // 基本信息
      model:{},
      options: [],
      // 产品属性
      Pattr:[],
      // model绑定的值
      // 产品名称定义的字符串
      biddingpname: '',
      biddingGrade:'',
      modelNum:'',
      modelPrice:'',
      modelinfo:'',
      modeltype: '',
      modelArea:'',      
      modelUnit:'',
      modelUse:'',
      modelprocessing:'',
    }
  },
  created() {
    this._releaseProduct()
    // this.changeName()
  },
  computed: {

  },

  mounted() {

  },
  methods: {
    // 双向绑定
    // 产品名称
    changeName(type){
     
     if(type==1){
          const Nreg = /^[\u4e00-\u9fa5]{3,10}$/;
          if (this.biddingpname == "") {
            // console.log("格式错误")
            this.pnameShow = true;
            this.Pname = "不能为空";
          } else if (!Nreg.test(this.biddingpname)) {
            this.pnameShow = true;
            this.Pname = " 请输入汉字且是3-10位";
          } else {
            this.pnameShow = false;
            console.log(this.biddingpname)
          }
        }else if(type == 2){
          const Nreg = /^[\u4e00-\u9fa5]{3,10}$/;
          console.log(this.biddingGrade)
          if (this.biddingGrade == "") {
            // console.log("格式错误")
            this.gradeShow = true;
            this.wranGrade = "不能为空";
          } else if (!Nreg.test(this.biddingGrade)) {
            this.gradeShow = true;
            this.wranGrade = "请输入汉字且是3-10位";
          } else {
            this.gradeShow = false;
            //  console.log(this.biddingNum)
          }
        }else if(type==3){
          const Nreg = /^[\d]{3,10}$/;
          console.log(this.modelNum)
          if (this.modelNum == "") {
            // console.log("格式错误")
            this.numShow = true;
            this.wranNum = "不能为空";
          } else if (!Nreg.test(this.modelNum)) {
            this.numShow = true;
            this.wranNum = "请输入数量且是3-10位只能是数字";
          } else {
            this.numShow = false;
            //  console.log(this.biddingNum)
          }
        }else if(type ==4){
          const Nreg = /^[\d]{1,10}$/;
          console.log(this.modelPrice)
          
          if (this.modelPrice ==""){
            this.priceShow = true;
            this.warnPrice ="不能为空"
          } else if (!Nreg.test(this.priceShow)){
            this.gradeShow = true;
            this.warnPrice = "请输入数字且是1-10位";
       }else{
         this.gradeShow = false;
       }
     }
    },
    // 下拉菜单
    selectChange(){  
     
      if (this.modelArea == "选择发货地"){
       
      }else{
        console.log(11111, this.modelArea)

      }

    },
    selectName(){
     
      if (this.modeltype =="选择分类"){
       
      }else{
        console.log(2222,this.modeltype)
        
      }
    },
    selectChange(){
     
    },
    // 请求后台数据
    _releaseProduct() {
      let params = {
        params: {}
      }
      releaseProduct(params).then((res) => {
        console.log(233, res)
        this.options = res.Pinfo;
        this.Pattr = res.Pattr;
        // console.log(7777777,this.Pattr)
      })
    },
    // 保存
    keep() {
      console.log(this.biddingpname)
      this.listData = { "pname": this.biddingpname, "type": this.modeltype, "area": this.modelArea}
      console.log(555555,this.listData)
    },
    // 上传照片路径
    handleAvatarSuccess(res, file) {
      this.imageUrl = URL.createObjectURL(file.raw);
    },
    beforeAvatarUpload(file) {
      const isJPG = file.type === 'image/jpeg';
      const isLt2M = file.size / 1024 / 1024 < 2;
    }
  }
}
